<?php

declare(strict_types=1);

namespace app\cart\controller;

use app\cart\model\GoodsShopcar;
use app\CheckTokenController;

class Modify extends CheckTokenController
{
    public function index()
    {
        $params = $this->request->param();
        $DBGoodsShopcart = new GoodsShopcar();
        $info = $DBGoodsShopcart->where('goods_id', $params['goods_id'])->field('goods_id,number')->save($params);
        // 修改成功之后，返回最新的number
        if ($info) {
            $i = $DBGoodsShopcart->where('goods_id', $params['goods_id'])->field('goods_id,number')->find()->toArray();
            return result($i);
        }
        return result($info);
    }
}
